<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>S110_nRF51822/Source/ble/ble_services/ble_hids.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('ble__hids_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">S110_nRF51822/Source/ble/ble_services/ble_hids.c</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.</span>
<a name="l00002"></a>00002 <span class="comment"> *</span>
<a name="l00003"></a>00003 <span class="comment"> * The information contained herein is property of Nordic Semiconductor ASA.</span>
<a name="l00004"></a>00004 <span class="comment"> * Terms and conditions of usage are described in detail in NORDIC</span>
<a name="l00005"></a>00005 <span class="comment"> * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * Licensees are granted free, non-transferable use of the information. NO</span>
<a name="l00008"></a>00008 <span class="comment"> * WARRANTY of ANY KIND is provided. This heading must NOT be removed from</span>
<a name="l00009"></a>00009 <span class="comment"> * the file.</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * $LastChangedRevision$</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="ble__hids_8h.html">ble_hids.h</a>&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="nrf__assert_8h.html" title="Utilities for verifying program logic.">nrf_assert.h</a>&quot;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="nordic__common_8h.html" title="Common defines and macros for firmware developed by Nordic Semiconductor.">nordic_common.h</a>&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="ble__srv__common_8h.html">ble_srv_common.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="ble__uuid__util_8h.html">ble_uuid_util.h</a>&quot;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="ble__sdk__util_8h.html">ble_sdk_util.h</a>&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="comment">// Protocol Mode values</span>
<a name="l00024"></a>00024 <span class="preprocessor">#define PROTOCOL_MODE_BOOT               0x00                        </span>
<a name="l00025"></a>00025 <span class="preprocessor">#define PROTOCOL_MODE_REPORT             0x01                        </span>
<a name="l00027"></a>00027 <span class="preprocessor">// HID Control Point values</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define HIDS_CONTROL_POINT_SUSPEND       0                           </span>
<a name="l00029"></a>00029 <span class="preprocessor">#define HIDS_CONTROL_POINT_EXIT_SUSPEND  1                           </span>
<a name="l00031"></a>00031 <span class="preprocessor">#define DEFAULT_PROTOCOL_MODE            PROTOCOL_MODE_REPORT        </span>
<a name="l00032"></a>00032 <span class="preprocessor">#define INITIAL_VALUE_HID_CONTROL_POINT  HIDS_CONTROL_POINT_SUSPEND  </span>
<a name="l00034"></a>00034 <span class="preprocessor">#define ENCODED_HID_INFORMATION_LEN      4                           </span>
<a name="l00036"></a>00036 <span class="preprocessor">#define BOOT_KB_INPUT_REPORT_MAX_SIZE    8                           </span>
<a name="l00037"></a>00037 <span class="preprocessor">#define BOOT_KB_OUTPUT_REPORT_MAX_SIZE   1                           </span>
<a name="l00038"></a>00038 <span class="preprocessor">#define BOOT_MOUSE_INPUT_REPORT_MIN_SIZE 3                           </span>
<a name="l00039"></a>00039 <span class="preprocessor">#define BOOT_MOUSE_INPUT_REPORT_MAX_SIZE 8                           </span>
<a name="l00042"></a>00042 <span class="preprocessor">static ble_hids_char_id_t make_char_id(uint16_t uuid, uint8_t rep_type, uint8_t rep_index)</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span>{
<a name="l00044"></a>00044     <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a> char_id;
<a name="l00045"></a>00045     
<a name="l00046"></a>00046     char_id.<a class="code" href="structble__hids__char__id__t.html#aaa1ded1f77a9c12a196ed4ba2ce5f95d">uuid</a>      = uuid;
<a name="l00047"></a>00047     char_id.<a class="code" href="structble__hids__char__id__t.html#adb67e5aa0cee4224c7158f31bb19f365">rep_type</a>  = rep_type;
<a name="l00048"></a>00048     char_id.<a class="code" href="structble__hids__char__id__t.html#a3c1ebbe6469d7b832170d89afb48ec70">rep_index</a> = rep_index;
<a name="l00049"></a>00049     
<a name="l00050"></a>00050     <span class="keywordflow">return</span> char_id;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="keyword">static</span> <span class="keywordtype">void</span> on_connect(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__evt__t.html" title="Common BLE Event type, wrapping the module specific event reports.">ble_evt_t</a> * p_ble_evt)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056     uint32_t err_code;
<a name="l00057"></a>00057     uint16_t len;
<a name="l00058"></a>00058     uint8_t  default_protocol_mode;
<a name="l00059"></a>00059     
<a name="l00060"></a>00060     p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a> = p_ble_evt-&gt;evt.<a class="code" href="structble__evt__t.html#a91857ca158f0c4e43f610068772c7d3d">gatts_evt</a>.<a class="code" href="structble__gatts__evt__t.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a>;
<a name="l00061"></a>00061 
<a name="l00062"></a>00062     <span class="comment">// Set Protocol Mode characteristic value to default value</span>
<a name="l00063"></a>00063     len                   = <span class="keyword">sizeof</span>(uint8_t);
<a name="l00064"></a>00064     default_protocol_mode = DEFAULT_PROTOCOL_MODE;
<a name="l00065"></a>00065 
<a name="l00066"></a>00066     err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga4267755972361d620ae47d791feec4a5" title="Set the value of a given attribute.">ble_gatts_value_set</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a00a02869d10bf33ebf85305e0c9060a8">protocol_mode_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>, 
<a name="l00067"></a>00067                                    0, 
<a name="l00068"></a>00068                                    &amp;len,
<a name="l00069"></a>00069                                    &amp;default_protocol_mode);
<a name="l00070"></a>00070     <span class="keywordflow">if</span> ((err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>) &amp;&amp; (p_hids-&gt;<a class="code" href="structble__hids__s.html#a893a7b5845beb42d9e5b650fd012f7f1">error_handler</a> != NULL))
<a name="l00071"></a>00071     {
<a name="l00072"></a>00072         p_hids-&gt;<a class="code" href="structble__hids__s.html#a893a7b5845beb42d9e5b650fd012f7f1">error_handler</a>(err_code);
<a name="l00073"></a>00073     }
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <span class="keyword">static</span> <span class="keywordtype">void</span> on_disconnect(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__evt__t.html" title="Common BLE Event type, wrapping the module specific event reports.">ble_evt_t</a> * p_ble_evt)
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079     UNUSED_PARAMETER(p_ble_evt);
<a name="l00080"></a>00080     p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a> = <a class="code" href="group___b_l_e___c_o_n_n___h_a_n_d_l_e_s.html#gacf227b9b101dbcf08eccbbaba54e48f5">BLE_CONN_HANDLE_INVALID</a>;
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="keyword">static</span> <span class="keywordtype">void</span> on_control_point_write(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__gatts__evt__write__t.html" title="Event structure for BLE_GATTS_EVT_WRITE.">ble_gatts_evt_write_t</a> * p_evt_write)
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086    <span class="keywordflow">if</span> ((p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#a8aed22e2c7b283705ec82e0120515618">len</a> == 1) &amp;&amp; (p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a> != NULL))
<a name="l00087"></a>00087    {
<a name="l00088"></a>00088         <a class="code" href="structble__hids__evt__t.html" title="HID Service event.">ble_hids_evt_t</a> evt;
<a name="l00089"></a>00089         
<a name="l00090"></a>00090         <span class="comment">// HID Control Point written, propagate event to application</span>
<a name="l00091"></a>00091         <span class="keywordflow">switch</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#aa86e1085c6a16f60258f29c9d5fc2144">data</a>[0])
<a name="l00092"></a>00092         {
<a name="l00093"></a>00093             <span class="keywordflow">case</span> HIDS_CONTROL_POINT_SUSPEND:
<a name="l00094"></a>00094                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a2c517f6d4a3a253bd99b52cc67f34a8b">BLE_HIDS_EVT_HOST_SUSP</a>;
<a name="l00095"></a>00095                 <span class="keywordflow">break</span>;
<a name="l00096"></a>00096                 
<a name="l00097"></a>00097             <span class="keywordflow">case</span> HIDS_CONTROL_POINT_EXIT_SUSPEND:
<a name="l00098"></a>00098                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a6971e1a18ee6ee48d3aa2e046debba6b">BLE_HIDS_EVT_HOST_EXIT_SUSP</a>;
<a name="l00099"></a>00099                 <span class="keywordflow">break</span>;
<a name="l00100"></a>00100                 
<a name="l00101"></a>00101             <span class="keywordflow">default</span>:
<a name="l00102"></a>00102                 <span class="comment">// Illegal Control Point value, ignore</span>
<a name="l00103"></a>00103                 <span class="keywordflow">return</span>;
<a name="l00104"></a>00104         }
<a name="l00105"></a>00105         
<a name="l00106"></a>00106         p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>(p_hids, &amp;evt);
<a name="l00107"></a>00107     }
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 <span class="keyword">static</span> <span class="keywordtype">void</span> on_protocol_mode_write(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__gatts__evt__write__t.html" title="Event structure for BLE_GATTS_EVT_WRITE.">ble_gatts_evt_write_t</a> * p_evt_write)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113    <span class="keywordflow">if</span> ((p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#a8aed22e2c7b283705ec82e0120515618">len</a> == 1) &amp;&amp; (p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a> != NULL))
<a name="l00114"></a>00114    {
<a name="l00115"></a>00115         <a class="code" href="structble__hids__evt__t.html" title="HID Service event.">ble_hids_evt_t</a> evt;
<a name="l00116"></a>00116         
<a name="l00117"></a>00117         <span class="comment">// HID Protocol Mode written, propagate event to application</span>
<a name="l00118"></a>00118         <span class="keywordflow">switch</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#aa86e1085c6a16f60258f29c9d5fc2144">data</a>[0])
<a name="l00119"></a>00119         {
<a name="l00120"></a>00120             <span class="keywordflow">case</span> PROTOCOL_MODE_BOOT:
<a name="l00121"></a>00121                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a4bc01306b5a8d12443926c1761d49a3a">BLE_HIDS_EVT_BOOT_MODE_ENTERED</a>;
<a name="l00122"></a>00122                 <span class="keywordflow">break</span>;
<a name="l00123"></a>00123                 
<a name="l00124"></a>00124             <span class="keywordflow">case</span> PROTOCOL_MODE_REPORT:
<a name="l00125"></a>00125                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a42845071ff0875e098bd16723d57d72f">BLE_HIDS_EVT_REPORT_MODE_ENTERED</a>;
<a name="l00126"></a>00126                 <span class="keywordflow">break</span>;
<a name="l00127"></a>00127                 
<a name="l00128"></a>00128             <span class="keywordflow">default</span>:
<a name="l00129"></a>00129                 <span class="comment">// Illegal Protocol Mode value, ignore</span>
<a name="l00130"></a>00130                 <span class="keywordflow">return</span>;
<a name="l00131"></a>00131         }
<a name="l00132"></a>00132         
<a name="l00133"></a>00133         p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>(p_hids, &amp;evt);
<a name="l00134"></a>00134     }
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 <span class="keyword">static</span> <span class="keywordtype">void</span> on_cccd_write(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *            p_hids, 
<a name="l00139"></a>00139                           <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a> *    p_char_id,
<a name="l00140"></a>00140                           <a class="code" href="structble__gatts__evt__write__t.html" title="Event structure for BLE_GATTS_EVT_WRITE.">ble_gatts_evt_write_t</a> * p_evt_write)
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142     <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#a8aed22e2c7b283705ec82e0120515618">len</a> == 2)
<a name="l00143"></a>00143     {
<a name="l00144"></a>00144         <span class="comment">// CCCD written, update notification state</span>
<a name="l00145"></a>00145         <span class="keywordflow">if</span> (p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a> != NULL)
<a name="l00146"></a>00146         {
<a name="l00147"></a>00147             <a class="code" href="structble__hids__evt__t.html" title="HID Service event.">ble_hids_evt_t</a> evt;
<a name="l00148"></a>00148             
<a name="l00149"></a>00149             <span class="keywordflow">if</span> (<a class="code" href="group__ble__sdk__srv__common.html#ga11fd3cc1b15d4bec4accc37618305ccb" title="Inline function for decoding a CCCD value, and then testing if notification is enabled.">ble_srv_is_notification_enabled</a>(p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#aa86e1085c6a16f60258f29c9d5fc2144">data</a>))
<a name="l00150"></a>00150             {
<a name="l00151"></a>00151                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a65b1e55409e2bed5a0871ec15dff4875">BLE_HIDS_EVT_NOTIF_ENABLED</a>;
<a name="l00152"></a>00152             }
<a name="l00153"></a>00153             <span class="keywordflow">else</span>
<a name="l00154"></a>00154             {
<a name="l00155"></a>00155                 evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a> = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a71b3af5b42cc730e6ad0752b3ad5c581">BLE_HIDS_EVT_NOTIF_DISABLED</a>;
<a name="l00156"></a>00156             }
<a name="l00157"></a>00157             evt.params.notification.char_id = *p_char_id;
<a name="l00158"></a>00158 
<a name="l00159"></a>00159             p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>(p_hids, &amp;evt);
<a name="l00160"></a>00160         }
<a name="l00161"></a>00161     }
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164 
<a name="l00165"></a>00165 <span class="keyword">static</span> <span class="keywordtype">void</span> on_value_write(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a> * p_char_id)
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167     <span class="keywordflow">if</span> (p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a> != NULL)
<a name="l00168"></a>00168     {
<a name="l00169"></a>00169         <a class="code" href="structble__hids__evt__t.html" title="HID Service event.">ble_hids_evt_t</a> evt;
<a name="l00170"></a>00170         
<a name="l00171"></a>00171         evt.<a class="code" href="structble__hids__evt__t.html#a1cd4bcc9aa3fde6718c5bcebfdbed672">evt_type</a>                  = <a class="code" href="group__ble__sdk__srv__hids.html#gga621d899fc96687c922a0c65010bfc063a0afaaafa6865acd5725096b6c2f6faa6">BLE_HIDS_EVT_REP_CHAR_WRITE</a>;
<a name="l00172"></a>00172         evt.params.char_write.char_id = *p_char_id;
<a name="l00173"></a>00173 
<a name="l00174"></a>00174         p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>(p_hids, &amp;evt);
<a name="l00175"></a>00175     }
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 <span class="keyword">static</span> <span class="keywordtype">bool</span> inp_rep_cccd_identify(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *         p_hids,
<a name="l00180"></a>00180                                   uint16_t             handle,
<a name="l00181"></a>00181                                   <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a> * p_char_id)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183     uint8_t i;
<a name="l00184"></a>00184     
<a name="l00185"></a>00185     <span class="keywordflow">for</span> (i = 0; i &lt; p_hids-&gt;<a class="code" href="structble__hids__s.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a>; i++)
<a name="l00186"></a>00186     {
<a name="l00187"></a>00187         <span class="keywordflow">if</span> (handle == p_hids-&gt;<a class="code" href="structble__hids__s.html#a713a274bad390986573cebcf8f310fd9">inp_rep_array</a>[i].<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a2c7796d4eb58c25a1a724bcd9d5bf183">cccd_handle</a>)
<a name="l00188"></a>00188         {
<a name="l00189"></a>00189             *p_char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga68c96a715e7da13a4c19e699604475be">BLE_UUID_REPORT_CHAR</a>, BLE_HIDS_REP_TYPE_INPUT, i);
<a name="l00190"></a>00190             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00191"></a>00191         }
<a name="l00192"></a>00192     }
<a name="l00193"></a>00193     
<a name="l00194"></a>00194     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 
<a name="l00198"></a>00198 <span class="keyword">static</span> <span class="keywordtype">bool</span> rep_value_identify(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *         p_hids,
<a name="l00199"></a>00199                                uint16_t             handle,
<a name="l00200"></a>00200                                <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a> * p_char_id)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202     uint8_t i;
<a name="l00203"></a>00203     
<a name="l00204"></a>00204     <span class="keywordflow">for</span> (i = 0; i &lt; p_hids-&gt;<a class="code" href="structble__hids__s.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a>; i++)
<a name="l00205"></a>00205     {
<a name="l00206"></a>00206         <span class="keywordflow">if</span> (handle == p_hids-&gt;<a class="code" href="structble__hids__s.html#a713a274bad390986573cebcf8f310fd9">inp_rep_array</a>[i].<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00207"></a>00207         {
<a name="l00208"></a>00208             *p_char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga68c96a715e7da13a4c19e699604475be">BLE_UUID_REPORT_CHAR</a>, BLE_HIDS_REP_TYPE_INPUT, i);
<a name="l00209"></a>00209             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00210"></a>00210         }
<a name="l00211"></a>00211     }
<a name="l00212"></a>00212     
<a name="l00213"></a>00213     <span class="keywordflow">for</span> (i = 0; i &lt; p_hids-&gt;<a class="code" href="structble__hids__s.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a>; i++)
<a name="l00214"></a>00214     {
<a name="l00215"></a>00215         <span class="keywordflow">if</span> (handle == p_hids-&gt;<a class="code" href="structble__hids__s.html#a58fbf8f51b70c9adefe18987dfe967ce">outp_rep_array</a>[i].<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00216"></a>00216         {
<a name="l00217"></a>00217             *p_char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga68c96a715e7da13a4c19e699604475be">BLE_UUID_REPORT_CHAR</a>, BLE_HIDS_REP_TYPE_OUTPUT, i);
<a name="l00218"></a>00218             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00219"></a>00219         }
<a name="l00220"></a>00220     }
<a name="l00221"></a>00221     
<a name="l00222"></a>00222     <span class="keywordflow">for</span> (i = 0; i &lt; p_hids-&gt;<a class="code" href="structble__hids__s.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a>; i++)
<a name="l00223"></a>00223     {
<a name="l00224"></a>00224         <span class="keywordflow">if</span> (handle == p_hids-&gt;<a class="code" href="structble__hids__s.html#afec8e1156c8d044b2a4aa29cc17e5997">feature_rep_array</a>[i].<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00225"></a>00225         {
<a name="l00226"></a>00226             *p_char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga68c96a715e7da13a4c19e699604475be">BLE_UUID_REPORT_CHAR</a>, BLE_HIDS_REP_TYPE_FEATURE, i);
<a name="l00227"></a>00227             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00228"></a>00228         }
<a name="l00229"></a>00229     }
<a name="l00230"></a>00230     
<a name="l00231"></a>00231     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#ga70525a816fec301fa4c9d564831c440b" title="Funtion that evaluates the value written in CCCD.">on_write</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__evt__t.html" title="Common BLE Event type, wrapping the module specific event reports.">ble_evt_t</a> * p_ble_evt)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237     <a class="code" href="structble__gatts__evt__write__t.html" title="Event structure for BLE_GATTS_EVT_WRITE.">ble_gatts_evt_write_t</a> * p_evt_write = &amp;p_ble_evt-&gt;evt.<a class="code" href="structble__evt__t.html#a91857ca158f0c4e43f610068772c7d3d">gatts_evt</a>.params.<a class="code" href="structble__gatts__evt__t.html#a682c515271ef8a1b93b7643a1023e8b8">write</a>;
<a name="l00238"></a>00238     <a class="code" href="structble__hids__char__id__t.html" title="HID Service characteristic id.">ble_hids_char_id_t</a>      char_id;
<a name="l00239"></a>00239 
<a name="l00240"></a>00240     <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#a19f94e464efe3fde2d32c82dcc2542d6">hid_control_point_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00241"></a>00241     {
<a name="l00242"></a>00242         on_control_point_write(p_hids, p_evt_write);
<a name="l00243"></a>00243     }
<a name="l00244"></a>00244     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#a00a02869d10bf33ebf85305e0c9060a8">protocol_mode_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00245"></a>00245     {
<a name="l00246"></a>00246         on_protocol_mode_write(p_hids, p_evt_write);
<a name="l00247"></a>00247     }
<a name="l00248"></a>00248     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#a8ea8df85f97a4439ac1cda7f4d45e76f">boot_kb_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a2c7796d4eb58c25a1a724bcd9d5bf183">cccd_handle</a>)
<a name="l00249"></a>00249     {
<a name="l00250"></a>00250         char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga94d261ee725a4b6c163d9fac8e846583">BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR</a>, 0, 0);
<a name="l00251"></a>00251         on_cccd_write(p_hids, &amp;char_id, p_evt_write);
<a name="l00252"></a>00252     }
<a name="l00253"></a>00253     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#a8ea8df85f97a4439ac1cda7f4d45e76f">boot_kb_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00254"></a>00254     {
<a name="l00255"></a>00255         char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga94d261ee725a4b6c163d9fac8e846583">BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR</a>, 0, 0);
<a name="l00256"></a>00256         on_value_write(p_hids, &amp;char_id);
<a name="l00257"></a>00257     }
<a name="l00258"></a>00258     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#aa64bd39c1a5662916445b80fdecbb812">boot_mouse_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a2c7796d4eb58c25a1a724bcd9d5bf183">cccd_handle</a>)
<a name="l00259"></a>00259     {
<a name="l00260"></a>00260         char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga62fbfe0ad9fac820ca7e840e637b886b">BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR</a>, 0, 0);
<a name="l00261"></a>00261         on_cccd_write(p_hids, &amp;char_id, p_evt_write);
<a name="l00262"></a>00262     }
<a name="l00263"></a>00263     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a> == p_hids-&gt;<a class="code" href="structble__hids__s.html#aa64bd39c1a5662916445b80fdecbb812">boot_mouse_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>)
<a name="l00264"></a>00264     {
<a name="l00265"></a>00265         char_id = make_char_id(<a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga62fbfe0ad9fac820ca7e840e637b886b">BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR</a>, 0, 0);
<a name="l00266"></a>00266         on_value_write(p_hids, &amp;char_id);
<a name="l00267"></a>00267     }
<a name="l00268"></a>00268     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (inp_rep_cccd_identify(p_hids, p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a>, &amp;char_id))
<a name="l00269"></a>00269     {
<a name="l00270"></a>00270         on_cccd_write(p_hids, &amp;char_id, p_evt_write);
<a name="l00271"></a>00271     }
<a name="l00272"></a>00272     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (rep_value_identify(p_hids, p_evt_write-&gt;<a class="code" href="structble__gatts__evt__write__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a>, &amp;char_id))
<a name="l00273"></a>00273     {
<a name="l00274"></a>00274         on_value_write(p_hids, &amp;char_id);
<a name="l00275"></a>00275     }
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277 
<a name="l00278"></a>00278 
<a name="l00279"></a><a class="code" href="group__ble__sdk__srv__hids.html#ga77b3d388f18004a1e730b4f2bbee5cac">00279</a> <span class="keywordtype">void</span> <a class="code" href="group__ble__sdk__srv__hids.html#ga77b3d388f18004a1e730b4f2bbee5cac" title="HID Service BLE stack event handler.">ble_hids_on_ble_evt</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <a class="code" href="structble__evt__t.html" title="Common BLE Event type, wrapping the module specific event reports.">ble_evt_t</a> * p_ble_evt)
<a name="l00280"></a>00280 {
<a name="l00281"></a>00281     <span class="keywordflow">switch</span> (p_ble_evt-&gt;<a class="code" href="structble__evt__t.html#a50f33abba5627a26728ba30fffd9880a">header</a>.<a class="code" href="structble__evt__hdr__t.html#a826314e7ea25d4267621899efe6859f9">evt_id</a>)
<a name="l00282"></a>00282     {
<a name="l00283"></a>00283         <span class="keywordflow">case</span> <a class="code" href="group___b_l_e___g_a_p.html#ggabc5c98fcc1211af2b80116dd6e0a035daa0b4789724d202a13a5e7eab85c52957">BLE_GAP_EVT_CONNECTED</a>:
<a name="l00284"></a>00284             on_connect(p_hids, p_ble_evt);
<a name="l00285"></a>00285             <span class="keywordflow">break</span>;
<a name="l00286"></a>00286             
<a name="l00287"></a>00287         <span class="keywordflow">case</span> <a class="code" href="group___b_l_e___g_a_p.html#ggabc5c98fcc1211af2b80116dd6e0a035da057001bbd6ea9e615f19ef93cc0831ee">BLE_GAP_EVT_DISCONNECTED</a>:
<a name="l00288"></a>00288             on_disconnect(p_hids, p_ble_evt);
<a name="l00289"></a>00289             <span class="keywordflow">break</span>;
<a name="l00290"></a>00290             
<a name="l00291"></a>00291         <span class="keywordflow">case</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gga80155586fa275b28773c9b203f52cabaaa68b7764f5264ff092d2ad17851355ed">BLE_GATTS_EVT_WRITE</a>:
<a name="l00292"></a>00292             <a class="code" href="group__ble__sdk__app__pwr__mgmt__main.html#ga70525a816fec301fa4c9d564831c440b" title="Funtion that evaluates the value written in CCCD.">on_write</a>(p_hids, p_ble_evt);
<a name="l00293"></a>00293             <span class="keywordflow">break</span>;
<a name="l00294"></a>00294             
<a name="l00295"></a>00295         <span class="keywordflow">default</span>:
<a name="l00296"></a>00296             <span class="keywordflow">break</span>;
<a name="l00297"></a>00297     }
<a name="l00298"></a>00298 }
<a name="l00299"></a>00299 
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 <span class="keyword">static</span> uint32_t protocol_mode_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a>                    * p_hids,
<a name="l00302"></a>00302                                        <span class="keyword">const</span> <a class="code" href="structble__srv__security__mode__t.html" title="Security settings structure.">ble_srv_security_mode_t</a> * hids_protocol_mode_attr_md)
<a name="l00303"></a>00303 {
<a name="l00304"></a>00304     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00305"></a>00305     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00306"></a>00306     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00307"></a>00307     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00308"></a>00308     uint8_t             initial_protocol_mode;
<a name="l00309"></a>00309     
<a name="l00310"></a>00310     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00311"></a>00311     
<a name="l00312"></a>00312     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>          = 1;
<a name="l00313"></a>00313     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#a9f74c5baf3348f422cece8bb43d75386">write_wo_resp</a> = 1;
<a name="l00314"></a>00314     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>              = NULL;
<a name="l00315"></a>00315     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>                     = NULL;
<a name="l00316"></a>00316     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>                = NULL;
<a name="l00317"></a>00317     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>                     = NULL;
<a name="l00318"></a>00318     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>                     = NULL;
<a name="l00319"></a>00319     
<a name="l00320"></a>00320     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gaca379d6676c9d33db4a169702dfad527">BLE_UUID_PROTOCOL_MODE_CHAR</a>);
<a name="l00321"></a>00321     
<a name="l00322"></a>00322     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00323"></a>00323 
<a name="l00324"></a>00324     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = hids_protocol_mode_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00325"></a>00325     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = hids_protocol_mode_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00326"></a>00326     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00327"></a>00327     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00328"></a>00328     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00329"></a>00329     
<a name="l00330"></a>00330     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00331"></a>00331     
<a name="l00332"></a>00332     initial_protocol_mode = DEFAULT_PROTOCOL_MODE;
<a name="l00333"></a>00333     
<a name="l00334"></a>00334     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00335"></a>00335     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00336"></a>00336     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = <span class="keyword">sizeof</span>(uint8_t);
<a name="l00337"></a>00337     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00338"></a>00338     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = <span class="keyword">sizeof</span>(uint8_t);
<a name="l00339"></a>00339     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = &amp;initial_protocol_mode;
<a name="l00340"></a>00340     
<a name="l00341"></a>00341     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>,
<a name="l00342"></a>00342                                         &amp;char_md,
<a name="l00343"></a>00343                                         &amp;attr_char_value,
<a name="l00344"></a>00344                                         &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a00a02869d10bf33ebf85305e0c9060a8">protocol_mode_handles</a>);
<a name="l00345"></a>00345 }
<a name="l00346"></a>00346 
<a name="l00347"></a>00347 
<a name="l00348"></a>00348 <span class="keyword">static</span> uint32_t rep_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *                         p_hids,
<a name="l00349"></a>00349                              <a class="code" href="structble__gatts__char__properties__t.html" title="GATT Characteristic Properties.">ble_gatts_char_properties_t</a> *        p_properties,
<a name="l00350"></a>00350                              uint8_t                              max_len,
<a name="l00351"></a>00351                              <a class="code" href="structble__srv__report__ref__t.html" title="Value of a Report Reference descriptor.">ble_srv_report_ref_t</a> *               p_rep_ref,
<a name="l00352"></a>00352                              <a class="code" href="structble__hids__rep__char__t.html" title="HID Report characteristic structure. This contains various information for initialization of a Report...">ble_hids_rep_char_t</a> *                p_rep_char,
<a name="l00353"></a>00353                              <span class="keyword">const</span> <a class="code" href="structble__srv__cccd__security__mode__t.html" title="Security settings structure.">ble_srv_cccd_security_mode_t</a> * rep_ref_attr_md)
<a name="l00354"></a>00354 {
<a name="l00355"></a>00355     uint32_t            err_code;
<a name="l00356"></a>00356     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00357"></a>00357     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> cccd_md;
<a name="l00358"></a>00358     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00359"></a>00359     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00360"></a>00360     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00361"></a>00361     uint8_t             encoded_rep_ref[<a class="code" href="group__ble__sdk__srv__common.html#gafbfc0ef111ca725cc8bb500fd93301cc">BLE_SRV_ENCODED_REPORT_REF_LEN</a>];
<a name="l00362"></a>00362     
<a name="l00363"></a>00363     <span class="comment">// Add Report characteristic</span>
<a name="l00364"></a>00364     <span class="keywordflow">if</span> (p_properties-&gt;<a class="code" href="structble__gatts__char__properties__t.html#ab4ddab4f7ba8461e378ffa590bb15dd8">notify</a>)
<a name="l00365"></a>00365     {
<a name="l00366"></a>00366         memset(&amp;cccd_md, 0, <span class="keyword">sizeof</span>(cccd_md));
<a name="l00367"></a>00367         <a class="code" href="group___b_l_e___g_a_p___c_o_n_n___s_e_c___m_o_d_e___s_e_t___m_a_c_r_o_s.html#ga2abd1c711d49a4d4b1ab9bf27cafffbb" title="Set sec_mode pointed to by ptr to require no protection, open link.">BLE_GAP_CONN_SEC_MODE_SET_OPEN</a>(&amp;cccd_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>);
<a name="l00368"></a>00368         cccd_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = rep_ref_attr_md-&gt;cccd_write_perm;
<a name="l00369"></a>00369     }
<a name="l00370"></a>00370     
<a name="l00371"></a>00371     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00372"></a>00372     
<a name="l00373"></a>00373     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>  = *p_properties;
<a name="l00374"></a>00374     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a> = NULL;
<a name="l00375"></a>00375     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>        = NULL;
<a name="l00376"></a>00376     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>   = NULL;
<a name="l00377"></a>00377     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>        = (p_properties-&gt;<a class="code" href="structble__gatts__char__properties__t.html#ab4ddab4f7ba8461e378ffa590bb15dd8">notify</a>) ? &amp;cccd_md : NULL;
<a name="l00378"></a>00378     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>        = NULL;
<a name="l00379"></a>00379     
<a name="l00380"></a>00380     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga68c96a715e7da13a4c19e699604475be">BLE_UUID_REPORT_CHAR</a>);
<a name="l00381"></a>00381     
<a name="l00382"></a>00382     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00383"></a>00383 
<a name="l00384"></a>00384     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = rep_ref_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00385"></a>00385     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = rep_ref_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00386"></a>00386     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00387"></a>00387     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00388"></a>00388     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 1;
<a name="l00389"></a>00389     
<a name="l00390"></a>00390     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00391"></a>00391     
<a name="l00392"></a>00392     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00393"></a>00393     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00394"></a>00394     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = 0;
<a name="l00395"></a>00395     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00396"></a>00396     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = max_len;
<a name="l00397"></a>00397     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = NULL;
<a name="l00398"></a>00398     
<a name="l00399"></a>00399     err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>,
<a name="l00400"></a>00400                                             &amp;char_md,
<a name="l00401"></a>00401                                             &amp;attr_char_value,
<a name="l00402"></a>00402                                             &amp;p_rep_char-&gt;<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>);
<a name="l00403"></a>00403     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00404"></a>00404     {
<a name="l00405"></a>00405         <span class="keywordflow">return</span> err_code;
<a name="l00406"></a>00406     }
<a name="l00407"></a>00407 
<a name="l00408"></a>00408     <span class="comment">// Add Report Reference descriptor</span>
<a name="l00409"></a>00409     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#gaee4c1d5c54af835b686f10af4e630274">BLE_UUID_REPORT_REF_DESCR</a>);
<a name="l00410"></a>00410     
<a name="l00411"></a>00411     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00412"></a>00412 
<a name="l00413"></a>00413     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = rep_ref_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00414"></a>00414     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = rep_ref_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00415"></a>00415     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00416"></a>00416     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00417"></a>00417     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00418"></a>00418     
<a name="l00419"></a>00419     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00420"></a>00420     
<a name="l00421"></a>00421     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00422"></a>00422     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00423"></a>00423     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = <a class="code" href="group__ble__sdk__srv__common.html#gaebc3fc5316f1a6a67e830516b8f9aed5" title="Encode a Report Reference Descriptor.">ble_srv_report_ref_encode</a>(encoded_rep_ref, p_rep_ref);
<a name="l00424"></a>00424     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00425"></a>00425     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>;
<a name="l00426"></a>00426     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = encoded_rep_ref;
<a name="l00427"></a>00427     
<a name="l00428"></a>00428     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga4bb7f2d804e7416d47ba64f434ac1243" title="Add a descriptor to the local server database.">ble_gatts_descriptor_add</a>(p_rep_char-&gt;<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>,
<a name="l00429"></a>00429                                     &amp;attr_char_value,
<a name="l00430"></a>00430                                     &amp;p_rep_char-&gt;<a class="code" href="structble__hids__rep__char__t.html#afc6931d3e3729479f61a07b785b00971">ref_handle</a>);
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 
<a name="l00433"></a>00433 
<a name="l00434"></a>00434 <span class="keyword">static</span> uint32_t rep_map_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00435"></a>00435 {
<a name="l00436"></a>00436     uint32_t            err_code;
<a name="l00437"></a>00437     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00438"></a>00438     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00439"></a>00439     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00440"></a>00440     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00441"></a>00441     
<a name="l00442"></a>00442     <span class="comment">// Add Report Map characteristic</span>
<a name="l00443"></a>00443     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00444"></a>00444     
<a name="l00445"></a>00445     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a> = 1;
<a name="l00446"></a>00446     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>     = NULL;
<a name="l00447"></a>00447     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>            = NULL;
<a name="l00448"></a>00448     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>       = NULL;
<a name="l00449"></a>00449     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>            = NULL;
<a name="l00450"></a>00450     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>            = NULL;
<a name="l00451"></a>00451     
<a name="l00452"></a>00452     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga924b7414f19f56ab5a88bd4cabd96094">BLE_UUID_REPORT_MAP_CHAR</a>);
<a name="l00453"></a>00453     
<a name="l00454"></a>00454     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00455"></a>00455     
<a name="l00456"></a>00456     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#addddaca40513d1c3357ded4f527fda06">rep_map_attr_md</a>.<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00457"></a>00457     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#addddaca40513d1c3357ded4f527fda06">rep_map_attr_md</a>.<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00458"></a>00458     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00459"></a>00459     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00460"></a>00460     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 1;
<a name="l00461"></a>00461     
<a name="l00462"></a>00462     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00463"></a>00463     
<a name="l00464"></a>00464     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00465"></a>00465     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00466"></a>00466     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#ac78cff7af99787faad2a285dffdde08e">data_len</a>;
<a name="l00467"></a>00467     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00468"></a>00468     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#ac78cff7af99787faad2a285dffdde08e">data_len</a>;
<a name="l00469"></a>00469     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#a8304c4af5da6e830b86d7199dc9a22e6">p_data</a>;
<a name="l00470"></a>00470     
<a name="l00471"></a>00471     err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>,
<a name="l00472"></a>00472                                             &amp;char_md,
<a name="l00473"></a>00473                                             &amp;attr_char_value,
<a name="l00474"></a>00474                                             &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a974231b841c4c6cec6b01ffe1edc942f">rep_map_handles</a>);
<a name="l00475"></a>00475     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00476"></a>00476     {
<a name="l00477"></a>00477         <span class="keywordflow">return</span> err_code;
<a name="l00478"></a>00478     }
<a name="l00479"></a>00479     
<a name="l00480"></a>00480     <span class="keywordflow">if</span> (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#afac4e236cf6c28612177689913f2cbf6">p_ext_rep_ref</a> != NULL)
<a name="l00481"></a>00481     {
<a name="l00482"></a>00482         uint8_t encoded_rep_ref[<span class="keyword">sizeof</span>(<a class="code" href="structble__uuid128__t.html" title="128 bit UUID values.">ble_uuid128_t</a>)];
<a name="l00483"></a>00483         uint8_t encoded_rep_ref_len;
<a name="l00484"></a>00484         
<a name="l00485"></a>00485         <span class="comment">// Add External Report Reference descriptor</span>
<a name="l00486"></a>00486         <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga2972d92af18490b81dd0679328d199c4">BLE_UUID_EXTERNAL_REPORT_REF_DESCR</a>);
<a name="l00487"></a>00487         
<a name="l00488"></a>00488         memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00489"></a>00489 
<a name="l00490"></a>00490         <a class="code" href="group___b_l_e___g_a_p___c_o_n_n___s_e_c___m_o_d_e___s_e_t___m_a_c_r_o_s.html#ga99f7b13b3c63bcaffe700c9f28c3ee3f" title="Set sec_mode pointed to by ptr to require encryption, but no MITM protection.">BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM</a>(&amp;attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>);
<a name="l00491"></a>00491         <a class="code" href="group___b_l_e___g_a_p___c_o_n_n___s_e_c___m_o_d_e___s_e_t___m_a_c_r_o_s.html#ga1cf3822f8bb11e28931afbb9179665b7" title="Set sec_mode pointed to by ptr to have no access rights.">BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS</a>(&amp;attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>);
<a name="l00492"></a>00492 
<a name="l00493"></a>00493         attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a> = 0;
<a name="l00494"></a>00494         attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a> = 0;
<a name="l00495"></a>00495         attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>     = 0;
<a name="l00496"></a>00496         
<a name="l00497"></a>00497         err_code = <a class="code" href="group__ble__sdk__lib__uuid.html#ga8af3492a4ce7d3db30915dbcbd8e83b9" title="Encode the uuid_t structure into Little-Endian UUID bytes (16-bit or 128-bit).">ble_uuid_encode</a>(p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a185212c529a0c80d609800ecdfd9aef5">rep_map</a>.<a class="code" href="structble__hids__rep__map__init__t.html#afac4e236cf6c28612177689913f2cbf6">p_ext_rep_ref</a>,
<a name="l00498"></a>00498                                    &amp;encoded_rep_ref_len,
<a name="l00499"></a>00499                                    encoded_rep_ref);
<a name="l00500"></a>00500         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00501"></a>00501         {
<a name="l00502"></a>00502             <span class="keywordflow">return</span> err_code;
<a name="l00503"></a>00503         }
<a name="l00504"></a>00504         
<a name="l00505"></a>00505         memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00506"></a>00506     
<a name="l00507"></a>00507         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00508"></a>00508         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00509"></a>00509         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = encoded_rep_ref_len;
<a name="l00510"></a>00510         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00511"></a>00511         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>;
<a name="l00512"></a>00512         attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = encoded_rep_ref;
<a name="l00513"></a>00513         
<a name="l00514"></a>00514         err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga4bb7f2d804e7416d47ba64f434ac1243" title="Add a descriptor to the local server database.">ble_gatts_descriptor_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a974231b841c4c6cec6b01ffe1edc942f">rep_map_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>,
<a name="l00515"></a>00515                                             &amp;attr_char_value,
<a name="l00516"></a>00516                                             &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a90455387069a4532533ae098982f4fce">rep_map_ext_rep_ref_handle</a>);
<a name="l00517"></a>00517         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00518"></a>00518         {
<a name="l00519"></a>00519             <span class="keywordflow">return</span> err_code;
<a name="l00520"></a>00520         }
<a name="l00521"></a>00521     }
<a name="l00522"></a>00522     
<a name="l00523"></a>00523     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00524"></a>00524 }
<a name="l00525"></a>00525 
<a name="l00526"></a>00526 
<a name="l00527"></a>00527 <span class="keyword">static</span> uint32_t boot_inp_rep_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *                         p_hids,
<a name="l00528"></a>00528                                       uint16_t                             uuid,
<a name="l00529"></a>00529                                       uint8_t                              max_data_len,
<a name="l00530"></a>00530                                       <span class="keywordtype">bool</span>                                 is_writable,
<a name="l00531"></a>00531                                       <span class="keyword">const</span> <a class="code" href="structble__srv__cccd__security__mode__t.html" title="Security settings structure.">ble_srv_cccd_security_mode_t</a> * hids_inp_rep_attr_md,
<a name="l00532"></a>00532                                       <a class="code" href="structble__gatts__char__handles__t.html" title="GATT Characteristic Definition Handles.">ble_gatts_char_handles_t</a> *           p_char_handles)
<a name="l00533"></a>00533 {
<a name="l00534"></a>00534     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00535"></a>00535     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> cccd_md;
<a name="l00536"></a>00536     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00537"></a>00537     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00538"></a>00538     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00539"></a>00539     
<a name="l00540"></a>00540     memset(&amp;cccd_md, 0, <span class="keyword">sizeof</span>(cccd_md));
<a name="l00541"></a>00541 
<a name="l00542"></a>00542     <a class="code" href="group___b_l_e___g_a_p___c_o_n_n___s_e_c___m_o_d_e___s_e_t___m_a_c_r_o_s.html#ga2abd1c711d49a4d4b1ab9bf27cafffbb" title="Set sec_mode pointed to by ptr to require no protection, open link.">BLE_GAP_CONN_SEC_MODE_SET_OPEN</a>(&amp;cccd_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>);
<a name="l00543"></a>00543     cccd_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = hids_inp_rep_attr_md-&gt;cccd_write_perm;
<a name="l00544"></a>00544     
<a name="l00545"></a>00545     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00546"></a>00546     
<a name="l00547"></a>00547     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>   = 1;
<a name="l00548"></a>00548     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#a60e9c75aa693ad12f404344cffc12505">write</a>  = (is_writable) ? 1 : 0;
<a name="l00549"></a>00549     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ab4ddab4f7ba8461e378ffa590bb15dd8">notify</a> = 1;
<a name="l00550"></a>00550     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>       = NULL;
<a name="l00551"></a>00551     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>              = NULL;
<a name="l00552"></a>00552     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>         = NULL;
<a name="l00553"></a>00553     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>              = &amp;cccd_md;
<a name="l00554"></a>00554     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>              = NULL;
<a name="l00555"></a>00555     
<a name="l00556"></a>00556     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, uuid);
<a name="l00557"></a>00557     
<a name="l00558"></a>00558     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00559"></a>00559 
<a name="l00560"></a>00560     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = hids_inp_rep_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00561"></a>00561     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = hids_inp_rep_attr_md-&gt;<a class="code" href="structble__srv__cccd__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00562"></a>00562     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00563"></a>00563     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00564"></a>00564     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00565"></a>00565     
<a name="l00566"></a>00566     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00567"></a>00567     
<a name="l00568"></a>00568     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00569"></a>00569     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00570"></a>00570     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = 0;
<a name="l00571"></a>00571     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00572"></a>00572     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = max_data_len;
<a name="l00573"></a>00573     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = NULL;
<a name="l00574"></a>00574     
<a name="l00575"></a>00575     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>,
<a name="l00576"></a>00576                                         &amp;char_md,
<a name="l00577"></a>00577                                         &amp;attr_char_value,
<a name="l00578"></a>00578                                         p_char_handles);
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 
<a name="l00581"></a>00581 
<a name="l00582"></a>00582 <span class="keyword">static</span> uint32_t boot_kb_outp_rep_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00583"></a>00583 {
<a name="l00584"></a>00584     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00585"></a>00585     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00586"></a>00586     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00587"></a>00587     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00588"></a>00588     
<a name="l00589"></a>00589     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00590"></a>00590     
<a name="l00591"></a>00591     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>          = 1;
<a name="l00592"></a>00592     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#a60e9c75aa693ad12f404344cffc12505">write</a>         = 1;
<a name="l00593"></a>00593     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#a9f74c5baf3348f422cece8bb43d75386">write_wo_resp</a> = 1;
<a name="l00594"></a>00594     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>              = NULL;
<a name="l00595"></a>00595     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>                     = NULL;
<a name="l00596"></a>00596     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>                = NULL;
<a name="l00597"></a>00597     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>                     = NULL;
<a name="l00598"></a>00598     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>                     = NULL;
<a name="l00599"></a>00599     
<a name="l00600"></a>00600     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga9504eca7b4df3ce415dad46abd2ea24f">BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR</a>);
<a name="l00601"></a>00601     
<a name="l00602"></a>00602     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00603"></a>00603 
<a name="l00604"></a>00604     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aefb8bcf73c4b8d2ce0e483c14fcb84c5">hids_boot_kb_outp_rep</a>.<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00605"></a>00605     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aefb8bcf73c4b8d2ce0e483c14fcb84c5">hids_boot_kb_outp_rep</a>.<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00606"></a>00606     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00607"></a>00607     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00608"></a>00608     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00609"></a>00609     
<a name="l00610"></a>00610     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00611"></a>00611     
<a name="l00612"></a>00612     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00613"></a>00613     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00614"></a>00614     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = 0;
<a name="l00615"></a>00615     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00616"></a>00616     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = BOOT_KB_OUTPUT_REPORT_MAX_SIZE;
<a name="l00617"></a>00617     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = NULL;
<a name="l00618"></a>00618     
<a name="l00619"></a>00619     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>, &amp;char_md, &amp;attr_char_value,
<a name="l00620"></a>00620                                         &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#ada48a59407a75f6b349dc89ff8787257">boot_kb_outp_rep_handles</a>);
<a name="l00621"></a>00621 }
<a name="l00622"></a>00622 
<a name="l00623"></a>00623 
<a name="l00624"></a>00624 <span class="keyword">static</span> uint8_t encode_hid_information(uint8_t *                          p_encoded_buffer,
<a name="l00625"></a>00625                                       <span class="keyword">const</span> <a class="code" href="structble__hids__hid__information__t.html" title="HID Information characteristic value.">ble_hids_hid_information_t</a> * p_hid_information)
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627     uint8_t len = <a class="code" href="group__ble__sdk__lib__util.html#gab58c28346b89382397aa7a716bf9a178" title="Inline function for encoding a uint16 value.">uint16_encode</a>(p_hid_information-&gt;<a class="code" href="structble__hids__hid__information__t.html#a2a011dc5c6b8855b97d33d0e301a63ab">bcd_hid</a>, p_encoded_buffer);
<a name="l00628"></a>00628     
<a name="l00629"></a>00629     p_encoded_buffer[len++] = p_hid_information-&gt;<a class="code" href="structble__hids__hid__information__t.html#aec71958133a703cd76e766e8e3b26143">b_country_code</a>;
<a name="l00630"></a>00630     p_encoded_buffer[len++] = p_hid_information-&gt;<a class="code" href="structble__hids__hid__information__t.html#aa2585d779da0ab21273a8d92de9a0ebe">flags</a>;
<a name="l00631"></a>00631     
<a name="l00632"></a>00632     <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(len == ENCODED_HID_INFORMATION_LEN);
<a name="l00633"></a>00633     <span class="keywordflow">return</span> len;
<a name="l00634"></a>00634 }
<a name="l00635"></a>00635 
<a name="l00636"></a>00636 
<a name="l00637"></a>00637 <span class="keyword">static</span> uint32_t hid_information_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00638"></a>00638 {
<a name="l00639"></a>00639     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00640"></a>00640     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00641"></a>00641     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00642"></a>00642     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00643"></a>00643     uint8_t             encoded_hid_information[ENCODED_HID_INFORMATION_LEN];
<a name="l00644"></a>00644     uint8_t             hid_info_len;
<a name="l00645"></a>00645     
<a name="l00646"></a>00646     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00647"></a>00647     
<a name="l00648"></a>00648     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a> = 1;
<a name="l00649"></a>00649     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>     = NULL;
<a name="l00650"></a>00650     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>            = NULL;
<a name="l00651"></a>00651     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>       = NULL;
<a name="l00652"></a>00652     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>            = NULL;
<a name="l00653"></a>00653     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>            = NULL;
<a name="l00654"></a>00654     
<a name="l00655"></a>00655     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga135c81eceb357731fd6ca37f6a8831b9">BLE_UUID_HID_INFORMATION_CHAR</a>);
<a name="l00656"></a>00656     
<a name="l00657"></a>00657     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00658"></a>00658 
<a name="l00659"></a>00659     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aabc2c6085c0d6caccf6ff29021c1d126">hid_information</a>.<a class="code" href="structble__hids__hid__information__t.html#adbc2c94f45ebf2c86646573e90e9969a">char_attr_md</a>.<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00660"></a>00660     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aabc2c6085c0d6caccf6ff29021c1d126">hid_information</a>.<a class="code" href="structble__hids__hid__information__t.html#adbc2c94f45ebf2c86646573e90e9969a">char_attr_md</a>.<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00661"></a>00661     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00662"></a>00662     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00663"></a>00663     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00664"></a>00664     
<a name="l00665"></a>00665     hid_info_len = encode_hid_information(encoded_hid_information, &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aabc2c6085c0d6caccf6ff29021c1d126">hid_information</a>);
<a name="l00666"></a>00666     
<a name="l00667"></a>00667     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00668"></a>00668     
<a name="l00669"></a>00669     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00670"></a>00670     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00671"></a>00671     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = hid_info_len;
<a name="l00672"></a>00672     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00673"></a>00673     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>;
<a name="l00674"></a>00674     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = encoded_hid_information;
<a name="l00675"></a>00675     
<a name="l00676"></a>00676     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>, &amp;char_md, 
<a name="l00677"></a>00677                                         &amp;attr_char_value, 
<a name="l00678"></a>00678                                         &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#af5ab8070c643dd8ccc7975038fc7996e">hid_information_handles</a>);
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00681"></a>00681 
<a name="l00682"></a>00682 <span class="keyword">static</span> uint32_t hid_control_point_char_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids,
<a name="l00683"></a>00683                                            <span class="keyword">const</span> <a class="code" href="structble__srv__security__mode__t.html" title="Security settings structure.">ble_srv_security_mode_t</a> * hids_ctrl_point_attr_md)
<a name="l00684"></a>00684 {
<a name="l00685"></a>00685     <a class="code" href="structble__gatts__char__md__t.html" title="GATT Characteristic Medatadata.">ble_gatts_char_md_t</a> char_md;
<a name="l00686"></a>00686     <a class="code" href="structble__gatts__attr__t.html" title="GATT Attribute.">ble_gatts_attr_t</a>    attr_char_value;
<a name="l00687"></a>00687     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a>          ble_uuid;
<a name="l00688"></a>00688     <a class="code" href="structble__gatts__attr__md__t.html" title="Attribute metadata.">ble_gatts_attr_md_t</a> attr_md;
<a name="l00689"></a>00689     uint8_t             initial_hid_control_point;
<a name="l00690"></a>00690     
<a name="l00691"></a>00691     memset(&amp;char_md, 0, <span class="keyword">sizeof</span>(char_md));
<a name="l00692"></a>00692     
<a name="l00693"></a>00693     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d81476b727bf4053879046f72049b48">char_properties</a>.<a class="code" href="structble__gatts__char__properties__t.html#a9f74c5baf3348f422cece8bb43d75386">write_wo_resp</a> = 1;
<a name="l00694"></a>00694     char_md.<a class="code" href="structble__gatts__char__md__t.html#a48ddd998bdda2b2b93e305ba46137d41">p_char_user_desc</a>              = NULL;
<a name="l00695"></a>00695     char_md.<a class="code" href="structble__gatts__char__md__t.html#ad1fe5fdc8f07028e11054f2288c7fc14">p_char_pf</a>                     = NULL;
<a name="l00696"></a>00696     char_md.<a class="code" href="structble__gatts__char__md__t.html#a2bce0c863bf96476ad1629c676042d34">p_user_desc_md</a>                = NULL;
<a name="l00697"></a>00697     char_md.<a class="code" href="structble__gatts__char__md__t.html#a5d654340f27d7c8f113a45beebb50312">p_cccd_md</a>                     = NULL;
<a name="l00698"></a>00698     char_md.<a class="code" href="structble__gatts__char__md__t.html#a642bc361c2131bdf054da18ce4e9a3e7">p_sccd_md</a>                     = NULL;
<a name="l00699"></a>00699     
<a name="l00700"></a>00700     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga41e3674c6345ca159cae6a7f2260626e">BLE_UUID_HID_CONTROL_POINT_CHAR</a>);
<a name="l00701"></a>00701     
<a name="l00702"></a>00702     memset(&amp;attr_md, 0, <span class="keyword">sizeof</span>(attr_md));
<a name="l00703"></a>00703 
<a name="l00704"></a>00704     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>  = hids_ctrl_point_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#af0352a482ca2a1305ec5941bc4af0ec2">read_perm</a>;
<a name="l00705"></a>00705     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a> = hids_ctrl_point_attr_md-&gt;<a class="code" href="structble__srv__security__mode__t.html#a6060006e42afe1970aed0a8490f71445">write_perm</a>;
<a name="l00706"></a>00706     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ac68fa2d9eb5f49771a80414d2c6bb690">rd_defer</a>   = 0;
<a name="l00707"></a>00707     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#ad44d77b2d08d2dde61c9ccbb22fa7432">wr_defer</a>   = 0;
<a name="l00708"></a>00708     attr_md.<a class="code" href="structble__gatts__attr__md__t.html#a248864ad6fe6949aa81d376cdd7d07b4">vlen</a>       = 0;
<a name="l00709"></a>00709     
<a name="l00710"></a>00710     initial_hid_control_point = INITIAL_VALUE_HID_CONTROL_POINT;
<a name="l00711"></a>00711     
<a name="l00712"></a>00712     memset(&amp;attr_char_value, 0, <span class="keyword">sizeof</span>(attr_char_value));
<a name="l00713"></a>00713     
<a name="l00714"></a>00714     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a8af1eafb75d1d1e9c4cacf188fad299e">p_uuid</a>       = &amp;ble_uuid;
<a name="l00715"></a>00715     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a573caddb6f66206646fcf38fa7c1a211">p_attr_md</a>    = &amp;attr_md;
<a name="l00716"></a>00716     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a9e68f6d248f0c128406979df16f88255">init_len</a>     = <span class="keyword">sizeof</span>(uint8_t);
<a name="l00717"></a>00717     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a44cd93c5a44c06d426920c36a3971eb1">init_offs</a>    = 0;
<a name="l00718"></a>00718     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#a1a6c02276292f164788906e8d5a316e5">max_len</a>      = <span class="keyword">sizeof</span>(uint8_t);
<a name="l00719"></a>00719     attr_char_value.<a class="code" href="structble__gatts__attr__t.html#ac439d398694461e592c0af528994705e">p_init_value</a> = &amp;initial_hid_control_point;
<a name="l00720"></a>00720     
<a name="l00721"></a>00721     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#gae4a1d9149f4531d66d06bf289886106d" title="Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...">ble_gatts_characteristic_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>, &amp;char_md, 
<a name="l00722"></a>00722                                         &amp;attr_char_value, 
<a name="l00723"></a>00723                                         &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a19f94e464efe3fde2d32c82dcc2542d6">hid_control_point_handles</a>);
<a name="l00724"></a>00724 }
<a name="l00725"></a>00725 
<a name="l00726"></a>00726 
<a name="l00727"></a>00727 <span class="keyword">static</span> uint32_t inp_rep_characteristics_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *            p_hids,
<a name="l00728"></a>00728                                             <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00729"></a>00729 {
<a name="l00730"></a>00730     <span class="keywordflow">if</span> ((p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a> != 0) &amp;&amp; (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ace337c61c33de48831b81df503231cd2">p_inp_rep_array</a> != NULL))
<a name="l00731"></a>00731     {
<a name="l00732"></a>00732         uint8_t i;
<a name="l00733"></a>00733         
<a name="l00734"></a>00734         <span class="keywordflow">for</span> (i = 0; i &lt; p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a>; i++)
<a name="l00735"></a>00735         {
<a name="l00736"></a>00736             uint32_t                    err_code;
<a name="l00737"></a>00737             <a class="code" href="structble__hids__inp__rep__init__t.html" title="HID Service Input Report characteristic init structure. This contains all options and data needed for...">ble_hids_inp_rep_init_t</a> *   p_rep_init = &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ace337c61c33de48831b81df503231cd2">p_inp_rep_array</a>[i];
<a name="l00738"></a>00738             <a class="code" href="structble__gatts__char__properties__t.html" title="GATT Characteristic Properties.">ble_gatts_char_properties_t</a> properties;
<a name="l00739"></a>00739             
<a name="l00740"></a>00740             memset(&amp;properties, 0, <span class="keyword">sizeof</span>(properties));
<a name="l00741"></a>00741             
<a name="l00742"></a>00742             properties.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>   = <span class="keyword">true</span>;
<a name="l00743"></a>00743             properties.<a class="code" href="structble__gatts__char__properties__t.html#a60e9c75aa693ad12f404344cffc12505">write</a>  = p_rep_init-&gt;<a class="code" href="structble__hids__inp__rep__init__t.html#a0f34a6773b9be9d0d44ebad4070b973a">writable</a>;
<a name="l00744"></a>00744             properties.<a class="code" href="structble__gatts__char__properties__t.html#ab4ddab4f7ba8461e378ffa590bb15dd8">notify</a> = <span class="keyword">true</span>;
<a name="l00745"></a>00745         
<a name="l00746"></a>00746             err_code = rep_char_add(p_hids, 
<a name="l00747"></a>00747                                     &amp;properties, 
<a name="l00748"></a>00748                                     p_rep_init-&gt;<a class="code" href="structble__hids__inp__rep__init__t.html#a7e8c368b285fef6796e5b0fda9b89d8c">max_len</a>, 
<a name="l00749"></a>00749                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__inp__rep__init__t.html#a070c6ac5d77d97faf98946507b8f8b7b">rep_ref</a>, 
<a name="l00750"></a>00750                                     &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a713a274bad390986573cebcf8f310fd9">inp_rep_array</a>[i],
<a name="l00751"></a>00751                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__inp__rep__init__t.html#a7affa6c39815d70e8fe83c9b12b9c263">attr_md</a>);
<a name="l00752"></a>00752             <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00753"></a>00753             {
<a name="l00754"></a>00754                 <span class="keywordflow">return</span> err_code;
<a name="l00755"></a>00755             }
<a name="l00756"></a>00756         }
<a name="l00757"></a>00757     }
<a name="l00758"></a>00758     
<a name="l00759"></a>00759     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00760"></a>00760 }
<a name="l00761"></a>00761 
<a name="l00762"></a>00762 
<a name="l00763"></a>00763 <span class="keyword">static</span> uint32_t outp_rep_characteristics_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *            p_hids,
<a name="l00764"></a>00764                                              <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00765"></a>00765 {
<a name="l00766"></a>00766     <span class="keywordflow">if</span> ((p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a> != 0) &amp;&amp; (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a802761ce4dffd4e4cb45154c1a65790a">p_outp_rep_array</a> != NULL))
<a name="l00767"></a>00767     {
<a name="l00768"></a>00768         uint8_t i;
<a name="l00769"></a>00769         
<a name="l00770"></a>00770         <span class="keywordflow">for</span> (i = 0; i &lt; p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a>; i++)
<a name="l00771"></a>00771         {
<a name="l00772"></a>00772             uint32_t                    err_code;
<a name="l00773"></a>00773             <a class="code" href="structble__hids__outp__rep__init__t.html" title="HID Service Output Report characteristic init structure. This contains all options and data needed fo...">ble_hids_outp_rep_init_t</a> *  p_rep_init = &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a802761ce4dffd4e4cb45154c1a65790a">p_outp_rep_array</a>[i];
<a name="l00774"></a>00774             <a class="code" href="structble__gatts__char__properties__t.html" title="GATT Characteristic Properties.">ble_gatts_char_properties_t</a> properties;
<a name="l00775"></a>00775             
<a name="l00776"></a>00776             memset(&amp;properties, 0, <span class="keyword">sizeof</span>(properties));
<a name="l00777"></a>00777             
<a name="l00778"></a>00778             properties.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>          = <span class="keyword">true</span>;
<a name="l00779"></a>00779             properties.<a class="code" href="structble__gatts__char__properties__t.html#a60e9c75aa693ad12f404344cffc12505">write</a>         = <span class="keyword">true</span>;
<a name="l00780"></a>00780             properties.<a class="code" href="structble__gatts__char__properties__t.html#a9f74c5baf3348f422cece8bb43d75386">write_wo_resp</a> = <span class="keyword">true</span>;
<a name="l00781"></a>00781         
<a name="l00782"></a>00782             err_code = rep_char_add(p_hids, 
<a name="l00783"></a>00783                                     &amp;properties, 
<a name="l00784"></a>00784                                     p_rep_init-&gt;<a class="code" href="structble__hids__outp__rep__init__t.html#a7e8c368b285fef6796e5b0fda9b89d8c">max_len</a>, 
<a name="l00785"></a>00785                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__outp__rep__init__t.html#a070c6ac5d77d97faf98946507b8f8b7b">rep_ref</a>, 
<a name="l00786"></a>00786                                     &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a58fbf8f51b70c9adefe18987dfe967ce">outp_rep_array</a>[i],
<a name="l00787"></a>00787                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__outp__rep__init__t.html#a7affa6c39815d70e8fe83c9b12b9c263">attr_md</a>);
<a name="l00788"></a>00788             <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00789"></a>00789             {
<a name="l00790"></a>00790                 <span class="keywordflow">return</span> err_code;
<a name="l00791"></a>00791             }
<a name="l00792"></a>00792         }
<a name="l00793"></a>00793     }
<a name="l00794"></a>00794     
<a name="l00795"></a>00795     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00796"></a>00796 }
<a name="l00797"></a>00797 
<a name="l00798"></a>00798 
<a name="l00799"></a>00799 <span class="keyword">static</span> uint32_t feature_rep_characteristics_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> *            p_hids,
<a name="l00800"></a>00800                                                 <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00801"></a>00801 {
<a name="l00802"></a>00802     <span class="keywordflow">if</span> ((p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a> != 0) &amp;&amp; (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ad9bde41a48b05ac0c04ac8660e7ee9c3">p_feature_rep_array</a> != NULL))
<a name="l00803"></a>00803     {
<a name="l00804"></a>00804         uint8_t i;
<a name="l00805"></a>00805         
<a name="l00806"></a>00806         <span class="keywordflow">for</span> (i = 0; i &lt; p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a>; i++)
<a name="l00807"></a>00807         {
<a name="l00808"></a>00808             uint32_t                      err_code;
<a name="l00809"></a>00809             <a class="code" href="structble__hids__feature__rep__init__t.html" title="HID Service Feature Report characteristic init structure. This contains all options and data needed f...">ble_hids_feature_rep_init_t</a> * p_rep_init = &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ad9bde41a48b05ac0c04ac8660e7ee9c3">p_feature_rep_array</a>[i];
<a name="l00810"></a>00810             <a class="code" href="structble__gatts__char__properties__t.html" title="GATT Characteristic Properties.">ble_gatts_char_properties_t</a>   properties;
<a name="l00811"></a>00811             
<a name="l00812"></a>00812             memset(&amp;properties, 0, <span class="keyword">sizeof</span>(properties));
<a name="l00813"></a>00813             
<a name="l00814"></a>00814             properties.<a class="code" href="structble__gatts__char__properties__t.html#ad99a3f990d972bf0b87f25fd507eb599">read</a>  = <span class="keyword">true</span>;
<a name="l00815"></a>00815             properties.<a class="code" href="structble__gatts__char__properties__t.html#a60e9c75aa693ad12f404344cffc12505">write</a> = <span class="keyword">true</span>;
<a name="l00816"></a>00816         
<a name="l00817"></a>00817             err_code = rep_char_add(p_hids, 
<a name="l00818"></a>00818                                     &amp;properties, 
<a name="l00819"></a>00819                                     p_rep_init-&gt;<a class="code" href="structble__hids__feature__rep__init__t.html#a7e8c368b285fef6796e5b0fda9b89d8c">max_len</a>, 
<a name="l00820"></a>00820                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__feature__rep__init__t.html#a070c6ac5d77d97faf98946507b8f8b7b">rep_ref</a>, 
<a name="l00821"></a>00821                                     &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#afec8e1156c8d044b2a4aa29cc17e5997">feature_rep_array</a>[i],
<a name="l00822"></a>00822                                     &amp;p_rep_init-&gt;<a class="code" href="structble__hids__feature__rep__init__t.html#a7affa6c39815d70e8fe83c9b12b9c263">attr_md</a>);
<a name="l00823"></a>00823             <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00824"></a>00824             {
<a name="l00825"></a>00825                 <span class="keywordflow">return</span> err_code;
<a name="l00826"></a>00826             }
<a name="l00827"></a>00827         }
<a name="l00828"></a>00828     }
<a name="l00829"></a>00829     
<a name="l00830"></a>00830     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00831"></a>00831 }
<a name="l00832"></a>00832 
<a name="l00833"></a>00833 
<a name="l00834"></a>00834 uint32_t includes_add(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00835"></a>00835 {
<a name="l00836"></a>00836     uint32_t err_code;
<a name="l00837"></a>00837     uint8_t  i;
<a name="l00838"></a>00838     uint16_t unused_include_handle;
<a name="l00839"></a>00839     
<a name="l00840"></a>00840     <span class="keywordflow">for</span> (i = 0; i &lt; p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a4939f849bfe8f354935e82db0c37e500">included_services_count</a>; i++)
<a name="l00841"></a>00841     {
<a name="l00842"></a>00842         err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga553f8deef66ea239ced4fe7efc82106b" title="Add an include declaration to the local server database.">ble_gatts_include_add</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>,
<a name="l00843"></a>00843                                          p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a2da787144c7b5ec4bf22c8d02d0a3186">p_included_services_array</a>[i],
<a name="l00844"></a>00844                                          &amp;unused_include_handle);
<a name="l00845"></a>00845         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00846"></a>00846         {
<a name="l00847"></a>00847             <span class="keywordflow">return</span> err_code;
<a name="l00848"></a>00848         }
<a name="l00849"></a>00849     }
<a name="l00850"></a>00850     
<a name="l00851"></a>00851     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00852"></a>00852 }
<a name="l00853"></a>00853 
<a name="l00854"></a>00854 
<a name="l00855"></a><a class="code" href="group__ble__sdk__srv__hids.html#gaf0b5ac4400c5c10be0a32554a6ffb68a">00855</a> uint32_t <a class="code" href="group__ble__sdk__srv__hids.html#gaf0b5ac4400c5c10be0a32554a6ffb68a" title="Initialize the HID Service.">ble_hids_init</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, <span class="keyword">const</span> <a class="code" href="structble__hids__init__t.html" title="HID Service init structure. This contains all options and data needed for initialization of the servi...">ble_hids_init_t</a> * p_hids_init)
<a name="l00856"></a>00856 {
<a name="l00857"></a>00857     uint32_t   err_code;
<a name="l00858"></a>00858     <a class="code" href="structble__uuid__t.html" title="Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.">ble_uuid_t</a> ble_uuid;
<a name="l00859"></a>00859     
<a name="l00860"></a>00860     <span class="keywordflow">if</span> (
<a name="l00861"></a>00861         (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a> &gt; BLE_HIDS_MAX_INPUT_REP)
<a name="l00862"></a>00862         ||
<a name="l00863"></a>00863         (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a> &gt; BLE_HIDS_MAX_OUTPUT_REP)
<a name="l00864"></a>00864         ||
<a name="l00865"></a>00865         (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a> &gt; BLE_HIDS_MAX_FEATURE_REP)
<a name="l00866"></a>00866     )
<a name="l00867"></a>00867     {
<a name="l00868"></a>00868         <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga0a5831cf5092e0dd43a01869676ee076" title="Invalid Parameter.">NRF_ERROR_INVALID_PARAM</a>;
<a name="l00869"></a>00869     }
<a name="l00870"></a>00870     
<a name="l00871"></a>00871     <span class="comment">// Initialize service structure</span>
<a name="l00872"></a>00872     p_hids-&gt;<a class="code" href="structble__hids__s.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>                 = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#aec4ea916000444b65d161b03d078386b">evt_handler</a>;
<a name="l00873"></a>00873     p_hids-&gt;<a class="code" href="structble__hids__s.html#a893a7b5845beb42d9e5b650fd012f7f1">error_handler</a>               = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a893a7b5845beb42d9e5b650fd012f7f1">error_handler</a>;
<a name="l00874"></a>00874     p_hids-&gt;<a class="code" href="structble__hids__s.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a>               = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a6779c4c746ce0d2b8aea6d532e6ad46d">inp_rep_count</a>;
<a name="l00875"></a>00875     p_hids-&gt;<a class="code" href="structble__hids__s.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a>              = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac502f18e0e0fb7c42ae9ba83de452e39">outp_rep_count</a>;
<a name="l00876"></a>00876     p_hids-&gt;<a class="code" href="structble__hids__s.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a>           = p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a188334a4e9d4695a90263e843b9985a3">feature_rep_count</a>;
<a name="l00877"></a>00877     p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a>                 = <a class="code" href="group___b_l_e___c_o_n_n___h_a_n_d_l_e_s.html#gacf227b9b101dbcf08eccbbaba54e48f5">BLE_CONN_HANDLE_INVALID</a>;
<a name="l00878"></a>00878     
<a name="l00879"></a>00879     <span class="comment">// Add service</span>
<a name="l00880"></a>00880     <a class="code" href="group__ble__types.html#gac4478362651889d2ade8030f53713588" title="Set .type and .uuid fields of ble_uuid_struct to specified uuid value.">BLE_UUID_BLE_ASSIGN</a>(ble_uuid, <a class="code" href="group___u_u_i_d___s_e_r_v_i_c_e_s.html#gaafd551131de655ea5987ed148170bf2d">BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE</a>);
<a name="l00881"></a>00881 
<a name="l00882"></a>00882     err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga5e8270fe6dfa01e446be17b48fe81e2a" title="Add a service declaration to the local server database.">ble_gatts_service_add</a>(<a class="code" href="group___b_l_e___g_a_t_t_s___s_v_c___t_y_p_e_s.html#ga713ed30865fa70c89587ba981f114a91">BLE_GATTS_SVC_TYPE_PRIMARY</a>,
<a name="l00883"></a>00883                                      &amp;ble_uuid,
<a name="l00884"></a>00884                                      &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a363e00d9262febd8d752ed2f933be1e4">service_handle</a>);
<a name="l00885"></a>00885     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00886"></a>00886     {
<a name="l00887"></a>00887         <span class="keywordflow">return</span> err_code;
<a name="l00888"></a>00888     }
<a name="l00889"></a>00889     
<a name="l00890"></a>00890     <span class="comment">// Add includes</span>
<a name="l00891"></a>00891     err_code = includes_add(p_hids, p_hids_init);
<a name="l00892"></a>00892     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00893"></a>00893     {
<a name="l00894"></a>00894         <span class="keywordflow">return</span> err_code;
<a name="l00895"></a>00895     }
<a name="l00896"></a>00896     
<a name="l00897"></a>00897     <span class="keywordflow">if</span> (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ae213e686ada9be3db5d0145cafa44299">is_kb</a> || p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac5f51b1716e007423b10547f000a6bfa">is_mouse</a>)
<a name="l00898"></a>00898     {
<a name="l00899"></a>00899         <span class="comment">// Add Protocol Mode characteristic</span>
<a name="l00900"></a>00900         err_code = protocol_mode_char_add(p_hids, &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ade56d45b12aac7e9a01a3eb229a4d46a">hids_protocol_mode_attr_md</a>);
<a name="l00901"></a>00901         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00902"></a>00902         {
<a name="l00903"></a>00903             <span class="keywordflow">return</span> err_code;
<a name="l00904"></a>00904         }
<a name="l00905"></a>00905     }
<a name="l00906"></a>00906 
<a name="l00907"></a>00907     <span class="comment">// Add Input Report characteristics (if any)</span>
<a name="l00908"></a>00908     err_code = inp_rep_characteristics_add(p_hids, p_hids_init);
<a name="l00909"></a>00909     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00910"></a>00910     {
<a name="l00911"></a>00911         <span class="keywordflow">return</span> err_code;
<a name="l00912"></a>00912     }
<a name="l00913"></a>00913 
<a name="l00914"></a>00914     <span class="comment">// Add Output Report characteristics (if any)</span>
<a name="l00915"></a>00915     err_code = outp_rep_characteristics_add(p_hids, p_hids_init);
<a name="l00916"></a>00916     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00917"></a>00917     {
<a name="l00918"></a>00918         <span class="keywordflow">return</span> err_code;
<a name="l00919"></a>00919     }
<a name="l00920"></a>00920 
<a name="l00921"></a>00921     <span class="comment">// Add Feature Report characteristic (if any)</span>
<a name="l00922"></a>00922     err_code = feature_rep_characteristics_add(p_hids, p_hids_init);
<a name="l00923"></a>00923     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00924"></a>00924     {
<a name="l00925"></a>00925         <span class="keywordflow">return</span> err_code;
<a name="l00926"></a>00926     }
<a name="l00927"></a>00927     
<a name="l00928"></a>00928     <span class="comment">// Add Report Map characteristic</span>
<a name="l00929"></a>00929     err_code = rep_map_char_add(p_hids, p_hids_init);
<a name="l00930"></a>00930     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00931"></a>00931     {
<a name="l00932"></a>00932         <span class="keywordflow">return</span> err_code;
<a name="l00933"></a>00933     }
<a name="l00934"></a>00934 
<a name="l00935"></a>00935     <span class="keywordflow">if</span> (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ae213e686ada9be3db5d0145cafa44299">is_kb</a>)
<a name="l00936"></a>00936     {
<a name="l00937"></a>00937         <span class="comment">// Add Boot Keyboard Input Report characteristic</span>
<a name="l00938"></a>00938         err_code = boot_inp_rep_char_add(p_hids,
<a name="l00939"></a>00939                                          <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga94d261ee725a4b6c163d9fac8e846583">BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR</a>,
<a name="l00940"></a>00940                                          BOOT_KB_INPUT_REPORT_MAX_SIZE,
<a name="l00941"></a>00941                                          p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a883ca268e11cefa978f61749ebb21961">is_boot_kb_inp_rep_writable</a>,
<a name="l00942"></a>00942                                          &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a7600fbb6e31c2a49df7d9ee00d0ed8ef">hids_boot_kb_inp_rep</a>,
<a name="l00943"></a>00943                                          &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a8ea8df85f97a4439ac1cda7f4d45e76f">boot_kb_inp_rep_handles</a>);
<a name="l00944"></a>00944         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00945"></a>00945         {
<a name="l00946"></a>00946             <span class="keywordflow">return</span> err_code;
<a name="l00947"></a>00947         }
<a name="l00948"></a>00948         
<a name="l00949"></a>00949         <span class="comment">// Add Boot Keyboard Output Report characteristic</span>
<a name="l00950"></a>00950         err_code = boot_kb_outp_rep_char_add(p_hids, p_hids_init);
<a name="l00951"></a>00951         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00952"></a>00952         {
<a name="l00953"></a>00953             <span class="keywordflow">return</span> err_code;
<a name="l00954"></a>00954         }
<a name="l00955"></a>00955     }
<a name="l00956"></a>00956     
<a name="l00957"></a>00957     <span class="keywordflow">if</span> (p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#ac5f51b1716e007423b10547f000a6bfa">is_mouse</a>)
<a name="l00958"></a>00958     {
<a name="l00959"></a>00959         <span class="comment">// Add Boot Mouse Input Report characteristic</span>
<a name="l00960"></a>00960         err_code = boot_inp_rep_char_add(p_hids,
<a name="l00961"></a>00961                                          <a class="code" href="group___u_u_i_d___c_h_a_r_a_c_t_e_r_i_s_t_i_c_s.html#ga62fbfe0ad9fac820ca7e840e637b886b">BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR</a>,
<a name="l00962"></a>00962                                          BOOT_MOUSE_INPUT_REPORT_MAX_SIZE,
<a name="l00963"></a>00963                                          p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a504aafb4fb510eb9e2d1905f388695f5">is_boot_mouse_inp_rep_writable</a>,
<a name="l00964"></a>00964                                          &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a6915e9411623e91805f903234ded2397">hids_boot_mouse_inp_rep</a>,
<a name="l00965"></a>00965                                          &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#aa64bd39c1a5662916445b80fdecbb812">boot_mouse_inp_rep_handles</a>);
<a name="l00966"></a>00966         <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00967"></a>00967         {
<a name="l00968"></a>00968             <span class="keywordflow">return</span> err_code;
<a name="l00969"></a>00969         }
<a name="l00970"></a>00970     }
<a name="l00971"></a>00971     
<a name="l00972"></a>00972     <span class="comment">// Add HID Information characteristic</span>
<a name="l00973"></a>00973     err_code = hid_information_char_add(p_hids, p_hids_init);
<a name="l00974"></a>00974     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00975"></a>00975     {
<a name="l00976"></a>00976         <span class="keywordflow">return</span> err_code;
<a name="l00977"></a>00977     }
<a name="l00978"></a>00978 
<a name="l00979"></a>00979     <span class="comment">// Add HID Control Point characteristic</span>
<a name="l00980"></a>00980     err_code = hid_control_point_char_add(p_hids, &amp;p_hids_init-&gt;<a class="code" href="structble__hids__init__t.html#a41612c278036c148c70940b2ec5c2787">hids_ctrl_point</a>);
<a name="l00981"></a>00981     <span class="keywordflow">if</span> (err_code != <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l00982"></a>00982     {
<a name="l00983"></a>00983         <span class="keywordflow">return</span> err_code;
<a name="l00984"></a>00984     }
<a name="l00985"></a>00985     
<a name="l00986"></a>00986     <span class="keywordflow">return</span> <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>;
<a name="l00987"></a>00987 }
<a name="l00988"></a>00988 
<a name="l00989"></a>00989 
<a name="l00990"></a><a class="code" href="group__ble__sdk__srv__hids.html#gaebf0c8621a14c15990aeac30750fb5bc">00990</a> uint32_t <a class="code" href="group__ble__sdk__srv__hids.html#gaebf0c8621a14c15990aeac30750fb5bc" title="Send Input Report.">ble_hids_inp_rep_send</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids,
<a name="l00991"></a>00991                                uint8_t      rep_index,
<a name="l00992"></a>00992                                uint16_t     len,
<a name="l00993"></a>00993                                uint8_t *    p_data)
<a name="l00994"></a>00994 {
<a name="l00995"></a>00995     uint32_t err_code;
<a name="l00996"></a>00996 
<a name="l00997"></a>00997     <span class="keywordflow">if</span> (rep_index &lt; p_hids-&gt;inp_rep_count)
<a name="l00998"></a>00998     {
<a name="l00999"></a>00999         <a class="code" href="structble__hids__rep__char__t.html" title="HID Report characteristic structure. This contains various information for initialization of a Report...">ble_hids_rep_char_t</a> * p_rep_char = &amp;p_hids-&gt;<a class="code" href="structble__hids__s.html#a713a274bad390986573cebcf8f310fd9">inp_rep_array</a>[rep_index];
<a name="l01000"></a>01000         
<a name="l01001"></a>01001         <span class="keywordflow">if</span> (p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a> != <a class="code" href="group___b_l_e___c_o_n_n___h_a_n_d_l_e_s.html#gacf227b9b101dbcf08eccbbaba54e48f5">BLE_CONN_HANDLE_INVALID</a>)
<a name="l01002"></a>01002         {
<a name="l01003"></a>01003             <a class="code" href="structble__gatts__hvx__params__t.html" title="GATT HVx parameters.">ble_gatts_hvx_params_t</a> hvx_params;
<a name="l01004"></a>01004             uint16_t               hvx_len = len;
<a name="l01005"></a>01005             
<a name="l01006"></a>01006             memset(&amp;hvx_params, 0, <span class="keyword">sizeof</span>(hvx_params));
<a name="l01007"></a>01007             
<a name="l01008"></a>01008             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a>   = p_rep_char-&gt;<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>;
<a name="l01009"></a>01009             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a470560e997d7a639785b8b405de9df7d">indicate</a> = 0;
<a name="l01010"></a>01010             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#ac681806181c80437cfab37335f62ff39">offset</a>   = 0;
<a name="l01011"></a>01011             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a05aad1ca0c545a05986893ca0e1ed34f">p_len</a>    = &amp;hvx_len;
<a name="l01012"></a>01012             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a8304c4af5da6e830b86d7199dc9a22e6">p_data</a>   = p_data;
<a name="l01013"></a>01013             
<a name="l01014"></a>01014             err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#gaab41731020dbcc6b9b561d8129689308" title="Notify or Indicate an attribute value.">ble_gatts_hvx</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a>, &amp;hvx_params);
<a name="l01015"></a>01015             <span class="keywordflow">if</span> ((err_code == <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>) &amp;&amp; (hvx_len != len))
<a name="l01016"></a>01016             {
<a name="l01017"></a>01017                 err_code = <a class="code" href="group__nrf__error.html#ga4c61f2b54667506e90cc296721b2e658" title="Data size exceeds limit.">NRF_ERROR_DATA_SIZE</a>;
<a name="l01018"></a>01018             }
<a name="l01019"></a>01019         }
<a name="l01020"></a>01020         <span class="keywordflow">else</span>
<a name="l01021"></a>01021         {
<a name="l01022"></a>01022             err_code = <a class="code" href="group__nrf__error.html#gaf0aff2ba7864b34a36b4a96986e1851e" title="Invalid state, operation disallowed in this state.">NRF_ERROR_INVALID_STATE</a>;
<a name="l01023"></a>01023         }
<a name="l01024"></a>01024     }
<a name="l01025"></a>01025     <span class="keywordflow">else</span>
<a name="l01026"></a>01026     {
<a name="l01027"></a>01027         err_code = <a class="code" href="group__nrf__error.html#ga0a5831cf5092e0dd43a01869676ee076" title="Invalid Parameter.">NRF_ERROR_INVALID_PARAM</a>;
<a name="l01028"></a>01028     }
<a name="l01029"></a>01029     
<a name="l01030"></a>01030     <span class="keywordflow">return</span> err_code;
<a name="l01031"></a>01031 }
<a name="l01032"></a>01032 
<a name="l01033"></a>01033 
<a name="l01034"></a><a class="code" href="group__ble__sdk__srv__hids.html#ga30a528bd23ffe8ddea07d1960eb4c507">01034</a> uint32_t <a class="code" href="group__ble__sdk__srv__hids.html#ga30a528bd23ffe8ddea07d1960eb4c507" title="Send Boot Keyboard Input Report.">ble_hids_boot_kb_inp_rep_send</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids, uint16_t len, uint8_t * p_data)
<a name="l01035"></a>01035 {
<a name="l01036"></a>01036     uint32_t err_code;
<a name="l01037"></a>01037 
<a name="l01038"></a>01038     <span class="keywordflow">if</span> (p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a> != <a class="code" href="group___b_l_e___c_o_n_n___h_a_n_d_l_e_s.html#gacf227b9b101dbcf08eccbbaba54e48f5">BLE_CONN_HANDLE_INVALID</a>)
<a name="l01039"></a>01039     {
<a name="l01040"></a>01040         <a class="code" href="structble__gatts__hvx__params__t.html" title="GATT HVx parameters.">ble_gatts_hvx_params_t</a> hvx_params;
<a name="l01041"></a>01041         uint16_t               hvx_len = len;
<a name="l01042"></a>01042         
<a name="l01043"></a>01043         memset(&amp;hvx_params, 0, <span class="keyword">sizeof</span>(hvx_params));
<a name="l01044"></a>01044         
<a name="l01045"></a>01045         hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a>   = p_hids-&gt;<a class="code" href="structble__hids__s.html#a8ea8df85f97a4439ac1cda7f4d45e76f">boot_kb_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>;
<a name="l01046"></a>01046         hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a470560e997d7a639785b8b405de9df7d">indicate</a> = 0;
<a name="l01047"></a>01047         hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#ac681806181c80437cfab37335f62ff39">offset</a>   = 0;
<a name="l01048"></a>01048         hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a05aad1ca0c545a05986893ca0e1ed34f">p_len</a>    = &amp;hvx_len;
<a name="l01049"></a>01049         hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a8304c4af5da6e830b86d7199dc9a22e6">p_data</a>   = p_data;
<a name="l01050"></a>01050         
<a name="l01051"></a>01051         err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#gaab41731020dbcc6b9b561d8129689308" title="Notify or Indicate an attribute value.">ble_gatts_hvx</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a>, &amp;hvx_params);
<a name="l01052"></a>01052         <span class="keywordflow">if</span> ((err_code == <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>) &amp;&amp; (hvx_len != len))
<a name="l01053"></a>01053         {
<a name="l01054"></a>01054             err_code = <a class="code" href="group__nrf__error.html#ga4c61f2b54667506e90cc296721b2e658" title="Data size exceeds limit.">NRF_ERROR_DATA_SIZE</a>;
<a name="l01055"></a>01055         }
<a name="l01056"></a>01056     }
<a name="l01057"></a>01057     <span class="keywordflow">else</span>
<a name="l01058"></a>01058     {
<a name="l01059"></a>01059         err_code = <a class="code" href="group__nrf__error.html#gaf0aff2ba7864b34a36b4a96986e1851e" title="Invalid state, operation disallowed in this state.">NRF_ERROR_INVALID_STATE</a>;
<a name="l01060"></a>01060     }
<a name="l01061"></a>01061     
<a name="l01062"></a>01062     <span class="keywordflow">return</span> err_code;
<a name="l01063"></a>01063 }
<a name="l01064"></a>01064 
<a name="l01065"></a>01065 
<a name="l01066"></a><a class="code" href="group__ble__sdk__srv__hids.html#gafc9114dc1527bfdd5a961c57c35357e3">01066</a> uint32_t <a class="code" href="group__ble__sdk__srv__hids.html#gafc9114dc1527bfdd5a961c57c35357e3" title="Send Boot Mouse Input Report.">ble_hids_boot_mouse_inp_rep_send</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids,
<a name="l01067"></a>01067                                           uint8_t      buttons,
<a name="l01068"></a>01068                                           int8_t       x_delta,
<a name="l01069"></a>01069                                           int8_t       y_delta,
<a name="l01070"></a>01070                                           uint16_t     optional_data_len,
<a name="l01071"></a>01071                                           uint8_t *    p_optional_data)
<a name="l01072"></a>01072 {
<a name="l01073"></a>01073     uint32_t err_code;
<a name="l01074"></a>01074 
<a name="l01075"></a>01075     <span class="keywordflow">if</span> (p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a> != <a class="code" href="group___b_l_e___c_o_n_n___h_a_n_d_l_e_s.html#gacf227b9b101dbcf08eccbbaba54e48f5">BLE_CONN_HANDLE_INVALID</a>)
<a name="l01076"></a>01076     {
<a name="l01077"></a>01077         uint16_t hvx_len = BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len;
<a name="l01078"></a>01078         
<a name="l01079"></a>01079         <span class="keywordflow">if</span> (hvx_len &lt;= BOOT_MOUSE_INPUT_REPORT_MAX_SIZE)
<a name="l01080"></a>01080         {
<a name="l01081"></a>01081             uint8_t                buffer[BOOT_MOUSE_INPUT_REPORT_MAX_SIZE];
<a name="l01082"></a>01082             <a class="code" href="structble__gatts__hvx__params__t.html" title="GATT HVx parameters.">ble_gatts_hvx_params_t</a> hvx_params;
<a name="l01083"></a>01083 
<a name="l01084"></a>01084             <a class="code" href="nrf__assert_8h.html#a28301f76c53b643912da7c538f74e2c6" title="Assert empty when disabled.">ASSERT</a>(BOOT_MOUSE_INPUT_REPORT_MIN_SIZE == 3);
<a name="l01085"></a>01085             
<a name="l01086"></a>01086             <span class="comment">// Build buffer</span>
<a name="l01087"></a>01087             buffer[0] = buttons;
<a name="l01088"></a>01088             buffer[1] = (uint8_t)x_delta;
<a name="l01089"></a>01089             buffer[2] = (uint8_t)y_delta;
<a name="l01090"></a>01090             
<a name="l01091"></a>01091             <span class="keywordflow">if</span> (optional_data_len &gt; 0)
<a name="l01092"></a>01092             {
<a name="l01093"></a>01093                 memcpy(&amp;buffer[3], p_optional_data, optional_data_len);
<a name="l01094"></a>01094             }
<a name="l01095"></a>01095             
<a name="l01096"></a>01096             <span class="comment">// Pass buffer to stack</span>
<a name="l01097"></a>01097             memset(&amp;hvx_params, 0, <span class="keyword">sizeof</span>(hvx_params));
<a name="l01098"></a>01098             
<a name="l01099"></a>01099             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#af242d6e3b6108ea75e1eb236e94c8240">handle</a>   = p_hids-&gt;<a class="code" href="structble__hids__s.html#aa64bd39c1a5662916445b80fdecbb812">boot_mouse_inp_rep_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>;
<a name="l01100"></a>01100             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a470560e997d7a639785b8b405de9df7d">indicate</a> = 0;
<a name="l01101"></a>01101             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#ac681806181c80437cfab37335f62ff39">offset</a>   = 0;
<a name="l01102"></a>01102             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a05aad1ca0c545a05986893ca0e1ed34f">p_len</a>    = &amp;hvx_len;
<a name="l01103"></a>01103             hvx_params.<a class="code" href="structble__gatts__hvx__params__t.html#a8304c4af5da6e830b86d7199dc9a22e6">p_data</a>   = buffer;
<a name="l01104"></a>01104             
<a name="l01105"></a>01105             err_code = <a class="code" href="group___b_l_e___g_a_t_t_s.html#gaab41731020dbcc6b9b561d8129689308" title="Notify or Indicate an attribute value.">ble_gatts_hvx</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a0d5ffe38d68e48d81e61fc6a4999ae68">conn_handle</a>, &amp;hvx_params);
<a name="l01106"></a>01106             <span class="keywordflow">if</span> (
<a name="l01107"></a>01107                 (err_code == <a class="code" href="group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123" title="Successful command.">NRF_SUCCESS</a>)
<a name="l01108"></a>01108                 &amp;&amp;
<a name="l01109"></a>01109                 (hvx_len != BOOT_MOUSE_INPUT_REPORT_MIN_SIZE + optional_data_len)
<a name="l01110"></a>01110             )
<a name="l01111"></a>01111             {
<a name="l01112"></a>01112                 err_code = <a class="code" href="group__nrf__error.html#ga4c61f2b54667506e90cc296721b2e658" title="Data size exceeds limit.">NRF_ERROR_DATA_SIZE</a>;
<a name="l01113"></a>01113             }
<a name="l01114"></a>01114         }
<a name="l01115"></a>01115         <span class="keywordflow">else</span>
<a name="l01116"></a>01116         {
<a name="l01117"></a>01117             err_code = <a class="code" href="group__nrf__error.html#ga4c61f2b54667506e90cc296721b2e658" title="Data size exceeds limit.">NRF_ERROR_DATA_SIZE</a>;
<a name="l01118"></a>01118         }
<a name="l01119"></a>01119     }
<a name="l01120"></a>01120     <span class="keywordflow">else</span>
<a name="l01121"></a>01121     {
<a name="l01122"></a>01122         err_code = <a class="code" href="group__nrf__error.html#gaf0aff2ba7864b34a36b4a96986e1851e" title="Invalid state, operation disallowed in this state.">NRF_ERROR_INVALID_STATE</a>;
<a name="l01123"></a>01123     }
<a name="l01124"></a>01124     
<a name="l01125"></a>01125     <span class="keywordflow">return</span> err_code;
<a name="l01126"></a>01126 }
<a name="l01127"></a>01127 
<a name="l01128"></a>01128 
<a name="l01129"></a><a class="code" href="group__ble__sdk__srv__hids.html#ga66e5fb9cefb62e76a88f2cc229c55f70">01129</a> uint32_t <a class="code" href="group__ble__sdk__srv__hids.html#ga66e5fb9cefb62e76a88f2cc229c55f70" title="Get the current value of Output Report from the stack.">ble_hids_outp_rep_get</a>(<a class="code" href="structble__hids__s.html" title="HID Service structure. This contains various status information for the service.">ble_hids_t</a> * p_hids,
<a name="l01130"></a>01130                                uint8_t      rep_index,
<a name="l01131"></a>01131                                uint16_t     len,
<a name="l01132"></a>01132                                uint8_t      offset,
<a name="l01133"></a>01133                                uint8_t *    p_outp_rep)
<a name="l01134"></a>01134 {
<a name="l01135"></a>01135     <span class="keywordflow">return</span> <a class="code" href="group___b_l_e___g_a_t_t_s.html#ga9112e57e30d9d78b9c5682c55f1b502e" title="Get the value of a given attribute.">ble_gatts_value_get</a>(p_hids-&gt;<a class="code" href="structble__hids__s.html#a58fbf8f51b70c9adefe18987dfe967ce">outp_rep_array</a>[rep_index].<a class="code" href="structble__hids__rep__char__t.html#aee1cb1e27b722ea969623de53f101e86">char_handles</a>.<a class="code" href="structble__gatts__char__handles__t.html#a61c5d051b6f79d08236fae6cf7019e75">value_handle</a>,
<a name="l01136"></a>01136                                offset,
<a name="l01137"></a>01137                                &amp;len,
<a name="l01138"></a>01138                                p_outp_rep);
<a name="l01139"></a>01139 }
<a name="l01140"></a>01140 
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>ble_hids.c</b>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
